include io.asm

stack segment stack
	dw 128 dup (?)
stack ends

;;======================================================================
data segment
	Head db "Vasilenko Anatoly. Group 111.$"
	Input db "Enter please number: $"
	Output1 db "This number is composite.$"
	Output2 db "This number is primary.$"
	N dw ?
data ends
;;======================================================================

code segment 'code'
	assume ss:stack, ds:data, cs:code
start:
	mov ax,data
	mov ds,ax
	lea dx, Head
	outstr
	newline
	newline
	;;------------------------------------------------------------------
		lea dx, Input;
		outstr;
		
		inint N;
		mov bx, 2; //Find cx
		mov ax, N;
		mov dx, 0;
		div bx; N div 2
		dec ax; i = N div 2 - 1
		mov cx, ax;
		
		jcxz Primary;
	L:	mov ax, N;
		mov dx, 0;
		div bx;
		cmp dx, 0;
		je  short Composite;
		inc bx;
		Loop L;
		
	Primary:
		lea dx, Output2;
		outstr;
		newline;
		jmp the_end;
		
	Composite:
		lea dx, Output1;
		outstr;
		newline;
		jmp the_end;
	
	;;------------------------------------------------------------------
the_end:
	newline;
	mov ah,8
	int 21h
    finish
code ends

;;======================================================================
end start 

;;======================================================================
